package tt.doubleagent.data;

import java.util.ArrayList;
import java.util.Random;

public class WordPackage {
	public String ID;
	public String DisplayName;
	public String Tag;
	public int RuleV2;
	public double Price;
	public boolean Purchased;
	public boolean IsModified = false;
	public ArrayList<WordPair> WordPairList = new ArrayList<WordPair>();

	private Random rand = new Random();

	public WordPackage(String info) {
		String[] strs = info.split("\t");
		ID = strs[0];
		DisplayName = strs[1];
		Tag = strs[2];
		RuleV2 = Integer.parseInt(strs[3]);
		Price = Double.parseDouble(strs[4]);
		Purchased = Boolean.parseBoolean(strs[5]);
	}

	public WordPackage() {
		// TODO Auto-generated constructor stub
	}

	public WordPair getWordPair(String ID) {
		for (WordPair wp : WordPairList) {
			if (wp.ID.equals(ID))
				return wp;
		}
		return null;
	}

	public WordPair getNextUnusedWordPair() {
		for (WordPair wp : WordPairList) {
			if (wp.UsedCount == 0)
				return wp;
		}
		return null;
	}

	public WordPair getRandomWordPair() {

		int pos = rand.nextInt(WordPairList.size());
		return WordPairList.get(pos);

	}
}
